package com.ecnu.web.controller.incubation;

import com.ecnu.common.core.controller.BaseController;
import com.ecnu.common.core.domain.AjaxResult;
import com.ecnu.common.core.domain.model.LoginUser;
import com.ecnu.common.core.page.TableDataInfo;
import com.ecnu.system.domain.dto.incubation.TransferDTO;
import com.ecnu.system.service.IIncubationFactoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * ecnu_二期_活动_AI中间表 前端控制器
 * </p>
 *
 * @author zdn
 * @since 2025-10-17
 */
@RestController
@Api(tags = "二期_成果车间（前台）")
@RequestMapping("/incubation")
@Validated//用来校验controller参数带@notblack类似的注解
public class IncubationUseController extends BaseController {
    @Autowired
    private IIncubationFactoryService incubationFactoryService;
    private static LoginUser getProUser() {
        LoginUser loginUser = new LoginUser();
        //看情况是否需要优化--获取登录信息问题
        try {
            loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        } catch (Exception e) {

        }
        return loginUser;
    }

    @ApiOperation(value = "展示列表")
    @PostMapping("/transfer/list")
    public TableDataInfo listForTransfer(@RequestBody @Valid TransferDTO dto) {
        LoginUser proUser = getProUser();
        return incubationFactoryService.listForTransfer(dto,proUser);
    }


    @ApiOperation(value = "成果字典数量列表")
    @PostMapping("/transfer/dictionary")
    public AjaxResult dictionary(@RequestBody TransferDTO dto) {
        return incubationFactoryService.getAllFactoryStatistics(dto);
//        return null;
    }
    @ApiOperation(value = "筛选条件列")
    @GetMapping("/transfer/conditions")
    public AjaxResult listForConditions() {
        return incubationFactoryService.listForConditions();
    }
}
